<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  props: {
    info: { type: Object, required: true },
  },
});
</script>

<template>
  <view class="product-item">
    <view class="product-item-cover">
      <image
        class="product-item-img"
        :src="info.vertical_pic"
        mode="aspectFill"
      />
      <view class="product-item-position">{{ info.city_name }}</view>
    </view>
    <view class="product-item-content">
      <view class="product-item-name">{{ info.product_name }}</view>
      <view class="product-item-comment">
        <view class="product-item-score">
          {{ info.score }}<text class="product-item-score2">分</text>
        </view>
        <view class="product-item-comment2">“{{ info.last_comment }}”</view>
      </view>
      <view class="product-item-tag">
        <view class="product-item-date">{{ info.near_date_buy }}</view>
        <view class="product-item-tag2">{{ info.tag }}</view>
      </view>
      <view class="product-item-num">
        <view class="product-item-num2">{{ info.sold_count_str }}</view>
        <view class="product-item-price">
          <text class="product-item-price2">¥</text>{{ info.min_price
          }}<text class="product-item-price3">起</text>
        </view>
      </view>
    </view>
  </view>
</template>

<style lang="scss">
.product-item {
  position: relative;
  display: flex;

  .product-item-cover {
    position: relative;
    flex-shrink: 0;
  }

  .product-item-img {
    display: block;
    width: 170rpx;
    height: 240rpx;
    border-radius: 20rpx;
  }

  .product-item-position {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 40rpx;
    padding-left: 12rpx;
    padding-top: 6rpx;
    font-size: 24rpx;
    color: #ffffff;
    line-height: 34rpx;
    font-weight: bold;
    border-radius: 0 0 20rpx 20rpx;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0));
  }

  .product-item-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex-grow: 1;
    min-width: 0;
    margin-left: 20rpx;
  }

  .product-item-name {
    max-height: 88rpx;
    margin-bottom: 6rpx;
    font-size: 32rpx;
    color: #333333;
    line-height: 44rpx;
    font-weight: bold;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    text-overflow: ellipsis;
    overflow: hidden;
  }

  .product-item-comment {
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: 12rpx;
  }

  .product-item-score {
    flex-shrink: 0;
    font-size: 28rpx;
    color: #0bc6b2;
    line-height: 40rpx;
    font-weight: bold;
  }

  .product-item-score2 {
    margin-left: 2rpx;
    font-size: 24rpx;
    color: #0bc6b2;
    line-height: 34rpx;
    font-weight: 400;
  }

  .product-item-comment2 {
    flex-grow: 1;
    min-width: 0;
    margin-left: 4rpx;
    font-size: 24rpx;
    color: #666666;
    line-height: 34rpx;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }

  .product-item-tag {
    display: flex;
    align-items: center;
    width: 100%;
  }

  .product-item-date {
    flex-shrink: 0;
    font-size: 24rpx;
    color: #ff7900;
    line-height: 34rpx;
  }

  .product-item-tag2 {
    min-width: 0;
    padding: 0 8rpx;
    margin-left: 10rpx;
    font-size: 24rpx;
    color: #4e9b93;
    line-height: 28rpx;
    border-radius: 8rpx;
    border: 2rpx solid rgba(78, 155, 147, 0.2);
  }

  .product-item-num {
    display: flex;
    align-items: center;
    width: 100%;
    margin-top: auto;
  }

  .product-item-num2 {
    font-size: 24rpx;
    color: #999999;
    line-height: 32rpx;
  }

  .product-item-price {
    margin-left: auto;
    font-size: 36rpx;
    color: #fa6400;
    line-height: 36rpx;
    font-weight: bold;
  }

  .product-item-price2 {
    font-size: 28rpx;
    line-height: 28rpx;
  }

  .product-item-price3 {
    margin-left: 2rpx;
    font-size: 24rpx;
    color: #666666;
    line-height: 34rpx;
    font-weight: 400;
  }
}
</style>
